package com.airnews.ticket.util;

import android.content.Context;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.AnimationUtils;
import android.view.animation.LayoutAnimationController;
import android.view.animation.ScaleAnimation;

import com.airnews.ticket.R;

/**
 * 动画工具类
 * @author luoxz
 */
public class AnimUtils {

	
	/**
	 * 页面间切换动画
	 * @param context
	 * @param oldV
	 * @param newV
	 */
	public static void showAnim(Context context, View oldV, View newV) {
		Animation anim = AnimationUtils.loadAnimation(context, R.anim.zoom_exit);
		oldV.startAnimation(anim);

		anim = AnimationUtils.loadAnimation(context, R.anim.zoom_enter);
		newV.startAnimation(anim);
	}
	
	
	public static void showLeftRightAnim(Context context, View oldV, View newV) {
		Animation anim = AnimationUtils.loadAnimation(context, R.anim.slide_left);
		oldV.startAnimation(anim);

		anim = AnimationUtils.loadAnimation(context, R.anim.slide_right);
		newV.startAnimation(anim);
	}
	
	
	/**
	 * 列表展现动画#ORDER_NORMAL
	 * @return
	 */
	/*public static LayoutAnimationController getNormalAnimController(){
        return getAnimController(LayoutAnimationController.ORDER_NORMAL);
	}*/
	
	
	
	/**
	 * 列表展现动画
	 * @param order
	 * @return
	 */
	public static LayoutAnimationController getAnimController(int order){
		AnimationSet set = new AnimationSet(true);
        Animation animation = new AlphaAnimation(0.0f, 1.0f);
        animation.setDuration(500);
        set.addAnimation(animation);
        animation = new ScaleAnimation(0, 1, 0, 1, 1f, 1f);
        animation.setDuration(500);
        set.addAnimation(animation);
        set.addAnimation(animation);
        LayoutAnimationController controller =
                new LayoutAnimationController(set, 0.4f);
        controller.setOrder(order);
        return controller;
	}
}
